<?php
/**
 * @author Artur Bier <izatop@gmail.com>
 * @package Application.View
 *
 * @copyright TinyWEB CMS
 * @link http://tinywebcms.ru
 * @link http://cms.vingrad.ru
 * @version SVN: $Id$ 
 */
 
 /**
  * PlainPHPView
  */
class PlainPHPView extends Object 
{
	private $templates_dir;
	private $vars				= array();
	private $vars_context		= array();
	
    /**
     * Конструктор класса
     * 
     */
    public function __construct($templates_dir)
    {
    	$this->templates_dir = $templates_dir;
    	$this->assign('IView', $this);
    }
    
    public function assign($name, $value, $context = null)
    {
		$this->vars[$name] = $value;
    }
    
    public function fetch($template)
    {
    	ob_start();
    	extract($this->vars);
    	extract($this->vars_context);
    	include "{$this->templates_dir}/{$template}";
    	return ob_get_clean();
    }
    
    public function display($template)
    {
    	echo $this->fetch($template);
    }
}

/**
 * Tab: 4 spaces
 * Encoding: utf-8
 */
?>